namespace FutureApp.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class _20161129Person : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.FutureBag",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 30),
                        Color = c.String(nullable: false, maxLength: 30),
                        IsActive = c.Boolean(nullable: false),
                        BagId = c.Guid(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Bag_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.FutureUsers", t => t.CreatorUserId)
                .ForeignKey("dbo.FutureUsers", t => t.DeleterUserId)
                .ForeignKey("dbo.FutureUsers", t => t.LastModifierUserId)
                .ForeignKey("dbo.FutureStudent", t => t.BagId)
                .Index(t => t.BagId)
                .Index(t => t.DeleterUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.CreatorUserId);
            
            CreateTable(
                "dbo.FutureStudent",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 30),
                        Sex = c.Int(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                        TypeId = c.Guid(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Student_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.FutureUsers", t => t.CreatorUserId)
                .ForeignKey("dbo.FutureUsers", t => t.DeleterUserId)
                .ForeignKey("dbo.FutureUsers", t => t.LastModifierUserId)
                .ForeignKey("dbo.FutureType", t => t.TypeId)
                .Index(t => t.TypeId)
                .Index(t => t.DeleterUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.CreatorUserId);
            
            CreateTable(
                "dbo.FutureType",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 30),
                        IsActive = c.Boolean(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Type_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.FutureUsers", t => t.CreatorUserId)
                .ForeignKey("dbo.FutureUsers", t => t.DeleterUserId)
                .ForeignKey("dbo.FutureUsers", t => t.LastModifierUserId)
                .Index(t => t.DeleterUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.CreatorUserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.FutureStudent", "TypeId", "dbo.FutureType");
            DropForeignKey("dbo.FutureType", "LastModifierUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureType", "DeleterUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureType", "CreatorUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureBag", "BagId", "dbo.FutureStudent");
            DropForeignKey("dbo.FutureStudent", "LastModifierUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureStudent", "DeleterUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureStudent", "CreatorUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureBag", "LastModifierUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureBag", "DeleterUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureBag", "CreatorUserId", "dbo.FutureUsers");
            DropIndex("dbo.FutureType", new[] { "CreatorUserId" });
            DropIndex("dbo.FutureType", new[] { "LastModifierUserId" });
            DropIndex("dbo.FutureType", new[] { "DeleterUserId" });
            DropIndex("dbo.FutureStudent", new[] { "CreatorUserId" });
            DropIndex("dbo.FutureStudent", new[] { "LastModifierUserId" });
            DropIndex("dbo.FutureStudent", new[] { "DeleterUserId" });
            DropIndex("dbo.FutureStudent", new[] { "TypeId" });
            DropIndex("dbo.FutureBag", new[] { "CreatorUserId" });
            DropIndex("dbo.FutureBag", new[] { "LastModifierUserId" });
            DropIndex("dbo.FutureBag", new[] { "DeleterUserId" });
            DropIndex("dbo.FutureBag", new[] { "BagId" });
            DropTable("dbo.FutureType",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Type_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.FutureStudent",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Student_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.FutureBag",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Bag_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
        }
    }
}
